/**
 * <copyright>
 * </copyright>
 *
 */
package lco.cRLanguage.impl;

import lco.cRLanguage.Assignment;
import lco.cRLanguage.CRLanguagePackage;
import lco.cRLanguage.ScalarAssign;
import lco.cRLanguage.VectorialAssign;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Assignment</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lco.cRLanguage.impl.AssignmentImpl#getSa <em>Sa</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.AssignmentImpl#getVa <em>Va</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AssignmentImpl extends MinimalEObjectImpl.Container implements Assignment
{
  /**
   * The cached value of the '{@link #getSa() <em>Sa</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSa()
   * @generated
   * @ordered
   */
  protected ScalarAssign sa;

  /**
   * The cached value of the '{@link #getVa() <em>Va</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVa()
   * @generated
   * @ordered
   */
  protected VectorialAssign va;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AssignmentImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRLanguagePackage.Literals.ASSIGNMENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ScalarAssign getSa()
  {
    return sa;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSa(ScalarAssign newSa, NotificationChain msgs)
  {
    ScalarAssign oldSa = sa;
    sa = newSa;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.ASSIGNMENT__SA, oldSa, newSa);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSa(ScalarAssign newSa)
  {
    if (newSa != sa)
    {
      NotificationChain msgs = null;
      if (sa != null)
        msgs = ((InternalEObject)sa).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.ASSIGNMENT__SA, null, msgs);
      if (newSa != null)
        msgs = ((InternalEObject)newSa).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.ASSIGNMENT__SA, null, msgs);
      msgs = basicSetSa(newSa, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.ASSIGNMENT__SA, newSa, newSa));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public VectorialAssign getVa()
  {
    return va;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetVa(VectorialAssign newVa, NotificationChain msgs)
  {
    VectorialAssign oldVa = va;
    va = newVa;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.ASSIGNMENT__VA, oldVa, newVa);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVa(VectorialAssign newVa)
  {
    if (newVa != va)
    {
      NotificationChain msgs = null;
      if (va != null)
        msgs = ((InternalEObject)va).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.ASSIGNMENT__VA, null, msgs);
      if (newVa != null)
        msgs = ((InternalEObject)newVa).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.ASSIGNMENT__VA, null, msgs);
      msgs = basicSetVa(newVa, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.ASSIGNMENT__VA, newVa, newVa));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRLanguagePackage.ASSIGNMENT__SA:
        return basicSetSa(null, msgs);
      case CRLanguagePackage.ASSIGNMENT__VA:
        return basicSetVa(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRLanguagePackage.ASSIGNMENT__SA:
        return getSa();
      case CRLanguagePackage.ASSIGNMENT__VA:
        return getVa();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRLanguagePackage.ASSIGNMENT__SA:
        setSa((ScalarAssign)newValue);
        return;
      case CRLanguagePackage.ASSIGNMENT__VA:
        setVa((VectorialAssign)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.ASSIGNMENT__SA:
        setSa((ScalarAssign)null);
        return;
      case CRLanguagePackage.ASSIGNMENT__VA:
        setVa((VectorialAssign)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.ASSIGNMENT__SA:
        return sa != null;
      case CRLanguagePackage.ASSIGNMENT__VA:
        return va != null;
    }
    return super.eIsSet(featureID);
  }

} //AssignmentImpl
